import xlrd
import xlwt

Execl = xlrd.open_workbook("数据.xls")

# 获取一个工作表
# Worksheet = Execl.sheets()[0]
Worksheet = Execl.sheet_by_index(0)  # 根据下标获取工作表 例如 Sheet1、Sheet2、Sheet3

# 获取行数和列数
nrows = Worksheet.nrows  # 行
ncols = Worksheet.ncols  # 列

# 创建一个Workbook对象，相当于创建了一个Excel文件
workbook = xlwt.Workbook(encoding='utf-8')
print(nrows)
print("-------------行------------------")
for i in range(0, nrows):
    # print(Worksheet.row_values(i))a
    shuju = Worksheet.row_values(i)

    print(shuju)
    print(shuju[1])
    worksheet = workbook.add_sheet(shuju[1])
    worksheet.write(0, 0, shuju[0])
    workbook.save('输出.xls')

print("执行结束")
# print(ncols)
# print("-------------列------------------")
# for i in range(ncols):
#     print(Worksheet.col_values(i))


# print(Worksheet.cell(0, 0).value)
# print(Worksheet.cell(25,4).value)

# print(Worksheet.row(0)[0].value)
# print(Worksheet.col(0)[2].value)


# 创建一个workbook 设置编码
# workbook = xlwt.Workbook(encoding='utf-8')
# worksheet = workbook.add_sheet('My Worksheet')
# style = xlwt.XFStyle() # 初始化样式
# worksheet.write(0, 0, 'Unformatted value')      # 不带样式的写入
# workbook.save('文件/境外问卷调查哦.xls')             # 保存文件





